
var $form;
var form;
var $;
layui.config({
	base : "../../js/"
}).use(['form','layer','upload','laydate'],function(){
	form = layui.form();
	var layer = parent.layer === undefined ? layui.layer : parent.layer;
		$ = layui.jquery;
		$form = $('form');
		laydate = layui.laydate;
		
	var oid = window.sessionStorage.getItem("organizeId");
	var upResult = "";
    layui.upload({
    	elem: '.orgLoad', //绑定元素
    	url : $.httpRootPath() + "/api/web/load/lead-in/roster",
    	ext: 'xls',
  		type: 'file',
         success: function(res){
         	if(res.code != "00"){
         		showNotice("模板解析出错，具体请查看上传结果");
         		upResult ='<p>'+res.msg+'</p>';
         	}else{
         		upResult +='<p>-----'+res.msg+'-----</p>'
         		if(res.data.length == 0){
         			showNotice("上传结果为空");
         			upResult ='<p>'+'模板中未找到有效数据'+'</p>';
         		}else{
         			showNotice("数据处理完成，共"+res.data.length+"行数据");
         			
         			for(var i =0;i<res.data.length;i++){
         				var obj = res.data[i]
         				upResult += "<p>编号："+obj.memberNum+":"+obj.upState+"</p>"
         			}
         		}
         	}
         	$("#uploadResutl").html(upResult);
  		},
         error: function(){
         	showNotice("未知错误");
         	upResult ='<p>'+'未知错误'+'</p>';
    	},
    });
	function showNotice(result){
		layer.alert(result,{icon:6, title:'上传提示'});
	}
	$(".mem-mould-down").click(function() {
		if(oid == null) {
			layer.msg('获取组织Id失败', {icon: 0});
			return false;
		}
		var str = $.httpRootPath()+"/api/web/load/i/"+ oid + "/down/org";
		window.location.href = str;
	});
	
})
	